text_file = open("sample.txt", "w") n = text_file.write('Welcome to pythonexamples.org') text_file.close()